
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.CureMedicine;
import cn.edu.scau.cmi.hombio.domain.CureMethod;
import cn.edu.scau.cmi.hombio.domain.Medicine;
import cn.edu.scau.cmi.hombio.domain.Unit;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class CureMedicineServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CureMedicineService service;

	/**
	 * Instantiates a new CureMedicineServiceTest.
	 *
	 */
	public CureMedicineServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMethod entity
	* 
	 */
	@Test
	public void saveCureMedicineCureMethod() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMedicineCureMethod 
		Integer id = 0;
		CureMethod related_curemethod = new cn.edu.scau.cmi.hombio.domain.CureMethod();
		CureMedicine response = null;
		response = service.saveCureMedicineCureMethod(id, related_curemethod);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureMedicineCureMethod
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCureMedicineByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCureMedicineByPrimaryKey 
		Integer id_1 = 0;
		CureMedicine response = null;
		response = service.findCureMedicineByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findCureMedicineByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMethod entity
	* 
	 */
	@Test
	public void deleteCureMedicineCureMethod() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMedicineCureMethod 
		Integer curemedicine_id = 0;
		Integer related_curemethod_id = 0;
		CureMedicine response = null;
		response = service.deleteCureMedicineCureMethod(curemedicine_id, related_curemethod_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureMedicineCureMethod
	}

	/**
	 * Operation Unit Test
	* Delete an existing Unit entity
	* 
	 */
	@Test
	public void deleteCureMedicineUnit() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMedicineUnit 
		Integer curemedicine_id_1 = 0;
		Integer related_unit_id = 0;
		CureMedicine response = null;
		response = service.deleteCureMedicineUnit(curemedicine_id_1, related_unit_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureMedicineUnit
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deleteCureMedicineMedicine() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMedicineMedicine 
		Integer curemedicine_id_2 = 0;
		Integer related_medicine_id = 0;
		CureMedicine response = null;
		response = service.deleteCureMedicineMedicine(curemedicine_id_2, related_medicine_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureMedicineMedicine
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void saveCureMedicineMedicine() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMedicineMedicine 
		Integer id_2 = 0;
		Medicine related_medicine = new cn.edu.scau.cmi.hombio.domain.Medicine();
		CureMedicine response = null;
		response = service.saveCureMedicineMedicine(id_2, related_medicine);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureMedicineMedicine
	}

	/**
	 * Operation Unit Test
	* Return all CureMedicine entity
	* 
	 */
	@Test
	public void findAllCureMedicines() {
		// TODO: JUnit - Populate test inputs for operation: findAllCureMedicines 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CureMedicine> response = null;
		response = service.findAllCureMedicines(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCureMedicines
	}

	/**
	 * Operation Unit Test
	* Return a count of all CureMedicine entity
	* 
	 */
	@Test
	public void countCureMedicines() {
		Integer response = null;
		response = service.countCureMedicines();
		// TODO: JUnit - Add assertions to test outputs of operation: countCureMedicines
	}

	/**
	 * Operation Unit Test
	* Load an existing CureMedicine entity
	* 
	 */
	@Test
	public void loadCureMedicines() {
		Set<CureMedicine> response = null;
		response = service.loadCureMedicines();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCureMedicines
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMedicine entity
	* 
	 */
	@Test
	public void deleteCureMedicine() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMedicine 
		CureMedicine curemedicine = new cn.edu.scau.cmi.hombio.domain.CureMedicine();
		service.deleteCureMedicine(curemedicine);
	}

	/**
	 * Operation Unit Test
	* Save an existing Unit entity
	* 
	 */
	@Test
	public void saveCureMedicineUnit() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMedicineUnit 
		Integer id_3 = 0;
		Unit related_unit = new cn.edu.scau.cmi.hombio.domain.Unit();
		CureMedicine response = null;
		response = service.saveCureMedicineUnit(id_3, related_unit);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureMedicineUnit
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMedicine entity
	* 
	 */
	@Test
	public void saveCureMedicine() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMedicine 
		CureMedicine curemedicine_1 = new cn.edu.scau.cmi.hombio.domain.CureMedicine();
		service.saveCureMedicine(curemedicine_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
